package com.manydatabase.controller;


import com.manydatabase.entity.Agent;
import com.manydatabase.entity.Agent2;
import com.manydatabase.service.Agent2Service;
import com.manydatabase.service.AgentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhanggq
 * @since 2019-10-20
 */
@Controller
@RequestMapping("/agent")
@Api(value = "agent", description = "Agent")
public class AgentController {

    @Autowired
    private AgentService agentService;
    @Autowired
    private Agent2Service agent2Service;

    @ApiOperation(value = "insertAgent2", notes = "insertAgent2")
    @PostMapping("/insertAgent2")
    public void insertAgent2() {
        Agent2 agent2 = new Agent2();
        Agent query = agentService.query();
        BeanUtils.copyProperties(query, agent2);
        agent2Service.add(agent2);
        query.setName("哈哈哈");
        query.setId(String.valueOf(Integer.valueOf(query.getId()) + 1));
        agentService.add(query);
    }

    @ApiOperation(value = "addAgent2", notes = "addAgent2")
    @PostMapping("/addAgent2")
    public void addAgent2() {
        agentService.addAgent2();
    }

}

